﻿public class Demo

{
    public void Testone()
    {
        int[] a = { 9, 2, 7, 4, 5 };
        Console.WriteLine("待排列数组：" + string.Join(",", a));
        for (int i = 0; i < a.Length - 1; i++)
        {
            bool swapped = false;
            for (int j = 0; j < a.Length - 1 - i; j++)
            {
                if (a[j] > a[j + 1])
                {
                    int temp = a[j];
                    a[j] = a[j + 1];
                    a[j + 1] = temp;
                    swapped = true;
                }
            }

            Console.WriteLine($"第{i + 1}趟后: " + string.Join(" ", a));
            if (!swapped) break;
        }

        Console.WriteLine("最终结果: " + string.Join(" ", a));
        Console.ReadKey();



    }
    //作业2
    
    
    

    
}